SlideShare a Scribd company logo
1 of 46
Building Faster Websites
Craig Walker, Chief Technology Officer
What is Xero?
http://www.xero.com/signup/
Performance === Usability
Performance === Money
• Bing: +2s in response time = 4.3% LOSS
of revenue/user
• Google: +500ms in response time = 20%
LESS traffic
• Amazon: +100ms in response time = 1%
LESS sales
• Shopzilla: +5s response time led to 12%
increase in revenue & 25% increase in
page views
Receive
Last Byte
Send
Last Byte
Send Data
The HTTP Request
Server
Browser
Establish
Connection
Initial
Connection
Open Socket
Initial HTTP
Request
First Byte
Receive
First Byte
Send
First Byte
Content Download
ISP
Get IP
DNS
Lookup
5%
95%
25%
75%
Empty Cache Primed Cache
Focus on the front-end
• 75-95% of the end-user response time for
Xero customers was spent on the front
end
• Much easier to optimise than server side
performance
• Greater potential for improvement –
especially from a front-end users point of
view
• MySpace's Performance
Tracker
msfast.myspace.com
• MS Visual Round Trip
Analyzer
Lotsa tools!
• HTTPWatch
www.httpwatch.com
• AOL PageTest
www.webpagetest.org
The ones we use at Xero …
• Fiddler
www.fiddlertool.com
• Firebug
www.getfirebug.com
• YSlow
developer.yahoo.com/ysl
ow
We don't all run Windows 7 & IE8 …
6616
29275
15596
5318
27233
Browsers
Chrome IE7 IE8
Safari 4 Firefox 3
728
10891
20717
53065
1383
Operating Systems
Linux MacOSX
Vista XP
Windows 7
Fiddler
The Rules
Zip It!
• Significantly reduces download
size – 60-80% saving on text
based content
• 90% of browsers support
compression
• Benefits users & you too:
– Reduces traffic costs
– Doesn’t require code change
• Zip everything you can
– html, aspx, js, css, xml, txt, json,
ashx …
Fly’s down Zipped
Turning on HTTP
Compression
Things to be wary of with compression
…
• Make sure you test – don't assume compression
• Approximately 5% of users get uncompressed
responses
• Browsers (& other applications) indicate compression
support by sending Accept-Encoding: gzip,
deflate and responding with Content-Encoding:
gzip
• Some client software (anti-virus, anti-phishing) and
proxy servers can strip Accept-Encoding
• If Accept-Encoding is missing let your users know!
• Use Advanced Logging for IIS7 to track request &
response headers
http://www.iis.net/extensions/advancedlogging
Minify all static content
• CSS, JavaScript, XML, JSON, HTML can all be
minified
• Not a replacement for gzipping but is a perfect
accompaniment to it (we've seen up to 50% extra
savings)
• No shortage of tools:
– JSMin
– CSSTidy
– YUI Compressor
• JavaScript obfuscation can also be useful – just test
that your app still works afterwards
You don't really want people to read your code do
you?
Ext.DomHelper = function(){
var tempTableEl = null;
var emptyTags =
/^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|ar
ea|param|col)$/i;
var tableRe = /^table|tbody|tr|td$/i;
var createHtml = function(o){
if(typeof o == 'string'){
return o;
}
var b = "";
if (Ext.isArray(o)) {
for (var i = 0, l = o.length; i < l; i++) {
b += createHtml(o[i]);
}
return b;
}
if(!o.tag){
o.tag = "div";
}
b += "<" + o.tag;
for(var attr in o){
if(attr == "tag" || attr == "children" ||
attr == "cn" || attr == "html" || typeof o[attr] ==
"function") continue;
if(attr == "style"){
var s = o["style"];
if(typeof s == "function"){
s = s.call();
}
if(typeof s == "string"){
b += ' style="' + s + '"';
}else if(typeof s == "object"){
Ext.DomHelper=function(){var n=null;var
g=/^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|co
l)$/i;var b=/^table|tbody|tr|td$/i;var a=function(w){if(typeof
w=="string"){return w;}var q="";if(Ext.isArray(w)){for(var
u=0,r=w.length;u<r;u++){q+=a(w[u]);}return
q;}if(!w.tag){w.tag="div";}q+="<"+w.tag;for(var p in
w){if(p=="tag"||p=="children"||p=="cn"||p=="html"||typeof
w[p]=="function"){continue;}if(p=="style"){var v=w["style"];if(typeof
v=="function"){v=v.call();}if(typeof v=="string"){q+='
style="'+v+'"';}else{if(typeof v=="object"){q+=' style="';for(var t
in v){if(typeof
v[t]!="function"){q+=t+":"+v[t]+";";}}q+='"';}}}else{if(p=="cls"){q+=
' class="'+w["cls"]+'"';}else{if(p=="htmlFor"){q+='
for="'+w["htmlFor"]+'"';}else{q+="
"+p+'="'+w[p]+'"';}}}}if(g.test(w.tag)){q+="/>";}else{q+=">";var
x=w.children||w.cn;if(x){q+=a(x);}else{if(w.html){q+=w.html;}}q+="</"
+w.tag+">";}return q;};var o=function(v,q){var
u;if(Ext.isArray(v)){u=document.createDocumentFragment();for(var
t=0,r=v.length;t<r;t++){o(v[t],u);}}else{if(typeof
v=="string"){u=document.createTextNode(v);}else{u=document.createElem
ent(v.tag||"div");var s=!!u.setAttribute;for(var p in
v){if(p=="tag"||p=="children"||p=="cn"||p=="html"||p=="style"||typeof
v[p]=="function"){continue;}if(p=="cls"){u.className=v["cls"];}else{i
f(s){u.setAttribute(p,v[p]);}else{u[p]=v[p];}}}Ext.DomHelper.applySty
les(u,v.style);var
w=v.children||v.cn;if(w){o(w,u);}else{if(v.html){u.innerHTML=v.html;}
}}}if(q){q.appendChild(u);}return u;};var
k=function(v,t,r,u){n.innerHTML=[t,r,u].join("");var p=-
1,q=n;while(++p<v){q=q.firstChild;}return q;};var
l="<table>",e="</table>",c=l+"<tbody>",m="</tbody>"+e,i=c+"<tr>",d="<
/tr>"+m;var
h=function(p,q,s,r){if(!n){n=document.createElement("div");}var t;var
u=null;if(p=="td"){if(q=="afterbegin"||q=="beforeend"){return;}if(q==
"beforebegin"){u=s;s=s.parentNode;}else{u=s.nextSibling;s=s.parentNod
e;}t=k(4,i,r,d);}else{if(p=="tr"){if(q=="beforebegin"){u=s;s=s.parent
Node;t=k(3,c,r,m);}else{if(q=="afterend"){u=s.nextSibling;s=s.parentN
ode;t=k(3,c,r,m);}else{if(q=="afterbegin"){u=s.firstChild;}t=k(4,i,r,
d);}}}else{if(p=="tbody"){if(q=="beforebegin"){u=s;s=s.parentNode;t=k
(2,l,r,e);}else{if(q=="afterend"){u=s.nextSibling;s=s.parentNode;t=k(
2,l,r,e);}else{if(q=="afterbegin"){u=s.firstChild;}t=k(3,c,r,m);}}}el
se{if(q=="beforebegin"||q=="afterend"){return;}if(q=="afterbegin"){u=
s.firstChild;}t=k(2,l,r,e);}}}s.insertBefore(t,u);return
955KB -> 265KB 539KB -> 141KB
Reduce HTTP Requests
• Less components means a
faster page
• Every request is an overhead
• Combine scripts
• Combine CSS
• Combine images into CSS
Sprites
• Don’t rely on cache: 304’s are
still requests
CSS Sprites
• Combine all small images
into one large image
• Use CSS to control the
displaying of each image
The designers want what?
11 images
11 HTTP Requests
3.3 KB total size
Obey your thirst®
1 image
1 HTTP Request
1.6 KB total size
And the code?
<div class="buttons">
<span class="large green button">
<button type="button">
<span class="checkbox icon">
Approve
</span>
</button>
</span>
<span class="large blue button">
<button type="button">
<span>
Save
</span>
</button>
</span>
<span class="large red button">
<button type="button">
<span class="delete icon">
Delete
</span>
</button>
</span>
<span class="medium gray button">
<button type="button">
<span class="delete icon">
Cancel
</span>
</button>
</span>
</div>
.buttons span.button {
background:transparent url(buttons.png) no-repeat 0 0;
}
.buttons span.button button, .buttons span.button a {
background:transparent url(buttons.png) no-repeat 100% -120px;
}
.buttons span.blue {
background-position: 0 -30px;
}
.buttons span.blue button, .buttons span.blue a {
background-position: 100% -150px;
}
.buttons span.red {
background-position: 0 -60px;
}
.buttons span.red button, .buttons span.red a {
background-position: 100% -180px;
}
.buttons span.green {
background-position: 0 -90px;
}
.buttons span.green button, .buttons span.green a {
background-position: 100% -210px;
}
SpriteMe
Optimise images
• Use PNGs instead of GIFs
• Avoid alpha filters – can block rendering and
freeze the browser
• PNG8 is best and supported by IE6 (yes – even
with transparency
• Optimise further with tools like PNGOUT
• Make sure you have a favicon.ico:
• Every browser will request it
• Best not to respond with a 404
• Make it small and cacheable
12KB15KB
Maximise Parallel Downloads
• Most browsers are limited to 6 connections total and 2
connections per hostname
Browser Parallel Downloads
Firefox 3.x 6
Internet Explorer 7 2
Internet Explorer 8 6
Safari 3.x 4
Safari 4 4
Chrome 4
• Increase the number of hostnames to increase the number
of parallel downloads
• Don't overdo it! (DNS lookups are expensive so limit to 2-4
domains)
JavaScript external and on the bottom
• Move scripts to external files for both reuse and caching
• Promotes better script design
• Push scripts as low as possible
– Often difficult with document.write or with inline calls requiring
loaded JavaScript
– Be pragmatic – think about splitting JavaScript into “must be
loaded” and “can be loaded on demand”
• Scripts will block both downloading and rendering until
parsed
• Remove duplicate scripts (IE has a habit of downloading
them again)
Maximise the cache
• Understand the ratio of users with cached vs uncached
• Add an Expires header
– Not just for images – should be used on all static content
– Set a “Never expire” or far future expires policy if you can
– Reduces HTTP requests – once component is served, the
browser never asks for it again
– Date stamping in file names makes it easier
• Remove ETags
– ETags are another caching mechanism – sent with every request
– Uniquely created per web server – not good in web farms
– Just turn them off and use Expires headers instead
Use a CDN
• Content Delivery Network
• Distributes content closer to the last mile
• Distribute your static content before distributing your
dynamic content
• Akamai most popular but expensive for small sites
• Xero utilises a rudimentary CDN using IP lookup to
determine location
GET
Request
Response with
HTML document
Images
JS
CSS
How it works:
RegisterCSS("/common/style/xero.css", "screen")
RegisterJavascript("/common/scripts/xero.js")
<link rel="stylesheet" type="text/css" media="screen"
href="https://nzs1.xero.com/common/style/xero.css" />
<script type="text/javascript"
src="https://nzs2.xero.com/common/scripts/xero.js">
</script>
Get
location
from IP
Reduce cookie weight
• Cookies are sent back with
every request
• Keep cookie size small and
only store what's required –
use server-side storage for
everything else
• Consider cookie free domains
for static content
• And while we're at it – reduce
ViewState too!
Preloading …
• Preload components
you’ll need in the future
• Unconditional preload
– Xero login page preloads
all core components so that
the dashboard experience
is better
• Conditional preload
– Often based on where you
think a user might go to
next
YSlow
• Firebug extension
• Grades performance – not about
response times but about how
well a site has adopted the
techniques suggested
• Response time inversely
proportional to YSlow score –
get as close to A as possible to
get the maximum performance
gain
YSlow
Aptimize
• Plugin that works with both IIS &
Apache
• Merges CSS & JSS files
• Reduces & optimises images with
CSS sprites & CSS inlining
• Compresses content with
minification
• Improves caching
• Used by over 300 websites &
intranets
• And it does all this in real-time!
www.aptimize.com
Aptimize
Aptimizing Microsoft
• Microsoft used Aptimize to
speed up
sharepoint.microsoft.com
• HTTP requests reduced
from 96 to 35
• Sped up first view, repeat
view and start render by
over 50%
• YSlow went from an E to a
B
Things to take away
• Focus on the front-end
• Be an advocate for your users – isn't it nice to
have happy users?
• Faster web sites lead to:
– Better user experience
– Reduced operating expenses
– Increase revenue
www.xero.com

More Related Content

What's hot

Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19Katie Sylor-Miller
 
10 things you can do to speed up your web app today 2016
10 things you can do to speed up your web app today 201610 things you can do to speed up your web app today 2016
10 things you can do to speed up your web app today 2016Chris Love
 
Fast and Easy Website Tuneups
Fast and Easy Website TuneupsFast and Easy Website Tuneups
Fast and Easy Website TuneupsJeff Wisniewski
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxKarl-Henry Martinsson
 
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...Katie Sylor-Miller
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizationsChris Love
 
Optimizing web performance (Fronteers edition)
Optimizing web performance (Fronteers edition)Optimizing web performance (Fronteers edition)
Optimizing web performance (Fronteers edition)Dave Olsen
 
Web performance optimization for modern web applications
Web performance optimization for modern web applicationsWeb performance optimization for modern web applications
Web performance optimization for modern web applicationsChris Love
 
Develop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will loveDevelop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will loveChris Love
 
Stress Test Drupal on Amazon EC2 vs. RackSpace cloud
Stress Test Drupal on Amazon EC2 vs. RackSpace cloudStress Test Drupal on Amazon EC2 vs. RackSpace cloud
Stress Test Drupal on Amazon EC2 vs. RackSpace cloudAndy Kucharski
 
Cache Rules Everything Around Me
Cache Rules Everything Around MeCache Rules Everything Around Me
Cache Rules Everything Around MeRussell Heimlich
 
Performance as User Experience [AEADC 2018]
Performance as User Experience [AEADC 2018]Performance as User Experience [AEADC 2018]
Performance as User Experience [AEADC 2018]Aaron Gustafson
 
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...Distilled
 
Mobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPressMobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPressDanilo Ercoli
 
Improve WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of codeImprove WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of codeDanilo Ercoli
 
SearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital Marketers
SearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital MarketersSearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital Marketers
SearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital MarketersDistilled
 

What's hot (20)

Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
Happy Browser, Happy User! NY Web Performance Meetup 9/20/19
 
10 things you can do to speed up your web app today 2016
10 things you can do to speed up your web app today 201610 things you can do to speed up your web app today 2016
10 things you can do to speed up your web app today 2016
 
Fast and Easy Website Tuneups
Fast and Easy Website TuneupsFast and Easy Website Tuneups
Fast and Easy Website Tuneups
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the Box
 
AD102 - Break out of the Box
AD102 - Break out of the BoxAD102 - Break out of the Box
AD102 - Break out of the Box
 
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
 
Break out of The Box - Part 2
Break out of The Box - Part 2Break out of The Box - Part 2
Break out of The Box - Part 2
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
Optimizing web performance (Fronteers edition)
Optimizing web performance (Fronteers edition)Optimizing web performance (Fronteers edition)
Optimizing web performance (Fronteers edition)
 
Web performance optimization for modern web applications
Web performance optimization for modern web applicationsWeb performance optimization for modern web applications
Web performance optimization for modern web applications
 
Develop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will loveDevelop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will love
 
Stress Test Drupal on Amazon EC2 vs. RackSpace cloud
Stress Test Drupal on Amazon EC2 vs. RackSpace cloudStress Test Drupal on Amazon EC2 vs. RackSpace cloud
Stress Test Drupal on Amazon EC2 vs. RackSpace cloud
 
Cache Rules Everything Around Me
Cache Rules Everything Around MeCache Rules Everything Around Me
Cache Rules Everything Around Me
 
Performance as User Experience [AEADC 2018]
Performance as User Experience [AEADC 2018]Performance as User Experience [AEADC 2018]
Performance as User Experience [AEADC 2018]
 
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...
 
Mobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPressMobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPress
 
Improve WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of codeImprove WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of code
 
Please dont touch-3.6-jsday
Please dont touch-3.6-jsdayPlease dont touch-3.6-jsday
Please dont touch-3.6-jsday
 
SearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital Marketers
SearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital MarketersSearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital Marketers
SearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital Marketers
 
What is HTML 5?
What is HTML 5?What is HTML 5?
What is HTML 5?
 

Similar to Build Faster Websites

Client Side Performance @ Xero
Client Side Performance @ XeroClient Side Performance @ Xero
Client Side Performance @ XeroCraig Walker
 
High performance website
High performance websiteHigh performance website
High performance websiteChamnap Chhorn
 
Cvcc performance tuning
Cvcc performance tuningCvcc performance tuning
Cvcc performance tuningJohn McCaffrey
 
Day 7 - Make it Fast
Day 7 - Make it FastDay 7 - Make it Fast
Day 7 - Make it FastBarry Jones
 
10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App TodayChris Love
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceSpark::red
 
Responsive content
Responsive contentResponsive content
Responsive contenthonzie
 
PAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark TomlinsonPAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark TomlinsonNeotys
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)clickramanm
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...Amazon Web Services
 
Website Performance
Website PerformanceWebsite Performance
Website PerformanceHugo Fonseca
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalabilityTwinbit
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
SenchaCon Roadshow Irvine 2017
SenchaCon Roadshow Irvine 2017SenchaCon Roadshow Irvine 2017
SenchaCon Roadshow Irvine 2017Speedment, Inc.
 
A little journey into website optimization
A little journey into website optimizationA little journey into website optimization
A little journey into website optimizationStelian Firez
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterpriseTaylor Lovett
 

Similar to Build Faster Websites (20)

performance.ppt
performance.pptperformance.ppt
performance.ppt
 
Client Side Performance @ Xero
Client Side Performance @ XeroClient Side Performance @ Xero
Client Side Performance @ Xero
 
High performance website
High performance websiteHigh performance website
High performance website
 
Cvcc performance tuning
Cvcc performance tuningCvcc performance tuning
Cvcc performance tuning
 
Day 7 - Make it Fast
Day 7 - Make it FastDay 7 - Make it Fast
Day 7 - Make it Fast
 
Salesforce Performance hacks - Client Side
Salesforce Performance hacks - Client SideSalesforce Performance hacks - Client Side
Salesforce Performance hacks - Client Side
 
10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today
 
Web Performance Optimization (WPO)
Web Performance Optimization (WPO)Web Performance Optimization (WPO)
Web Performance Optimization (WPO)
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web Perormance
 
Responsive content
Responsive contentResponsive content
Responsive content
 
PAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark TomlinsonPAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark Tomlinson
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
 
Website Performance
Website PerformanceWebsite Performance
Website Performance
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
SenchaCon Roadshow Irvine 2017
SenchaCon Roadshow Irvine 2017SenchaCon Roadshow Irvine 2017
SenchaCon Roadshow Irvine 2017
 
A little journey into website optimization
A little journey into website optimizationA little journey into website optimization
A little journey into website optimization
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

Build Faster Websites

  • 1. Building Faster Websites Craig Walker, Chief Technology Officer
  • 4. Performance === Money • Bing: +2s in response time = 4.3% LOSS of revenue/user • Google: +500ms in response time = 20% LESS traffic • Amazon: +100ms in response time = 1% LESS sales • Shopzilla: +5s response time led to 12% increase in revenue & 25% increase in page views
  • 5.
  • 6. Receive Last Byte Send Last Byte Send Data The HTTP Request Server Browser Establish Connection Initial Connection Open Socket Initial HTTP Request First Byte Receive First Byte Send First Byte Content Download ISP Get IP DNS Lookup
  • 10. Focus on the front-end • 75-95% of the end-user response time for Xero customers was spent on the front end • Much easier to optimise than server side performance • Greater potential for improvement – especially from a front-end users point of view
  • 11. • MySpace's Performance Tracker msfast.myspace.com • MS Visual Round Trip Analyzer Lotsa tools! • HTTPWatch www.httpwatch.com • AOL PageTest www.webpagetest.org
  • 12. The ones we use at Xero … • Fiddler www.fiddlertool.com • Firebug www.getfirebug.com • YSlow developer.yahoo.com/ysl ow
  • 13. We don't all run Windows 7 & IE8 … 6616 29275 15596 5318 27233 Browsers Chrome IE7 IE8 Safari 4 Firefox 3 728 10891 20717 53065 1383 Operating Systems Linux MacOSX Vista XP Windows 7
  • 16. Zip It! • Significantly reduces download size – 60-80% saving on text based content • 90% of browsers support compression • Benefits users & you too: – Reduces traffic costs – Doesn’t require code change • Zip everything you can – html, aspx, js, css, xml, txt, json, ashx …
  • 19. Things to be wary of with compression … • Make sure you test – don't assume compression • Approximately 5% of users get uncompressed responses • Browsers (& other applications) indicate compression support by sending Accept-Encoding: gzip, deflate and responding with Content-Encoding: gzip • Some client software (anti-virus, anti-phishing) and proxy servers can strip Accept-Encoding • If Accept-Encoding is missing let your users know! • Use Advanced Logging for IIS7 to track request & response headers http://www.iis.net/extensions/advancedlogging
  • 20. Minify all static content • CSS, JavaScript, XML, JSON, HTML can all be minified • Not a replacement for gzipping but is a perfect accompaniment to it (we've seen up to 50% extra savings) • No shortage of tools: – JSMin – CSSTidy – YUI Compressor • JavaScript obfuscation can also be useful – just test that your app still works afterwards
  • 21. You don't really want people to read your code do you? Ext.DomHelper = function(){ var tempTableEl = null; var emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|ar ea|param|col)$/i; var tableRe = /^table|tbody|tr|td$/i; var createHtml = function(o){ if(typeof o == 'string'){ return o; } var b = ""; if (Ext.isArray(o)) { for (var i = 0, l = o.length; i < l; i++) { b += createHtml(o[i]); } return b; } if(!o.tag){ o.tag = "div"; } b += "<" + o.tag; for(var attr in o){ if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue; if(attr == "style"){ var s = o["style"]; if(typeof s == "function"){ s = s.call(); } if(typeof s == "string"){ b += ' style="' + s + '"'; }else if(typeof s == "object"){ Ext.DomHelper=function(){var n=null;var g=/^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|co l)$/i;var b=/^table|tbody|tr|td$/i;var a=function(w){if(typeof w=="string"){return w;}var q="";if(Ext.isArray(w)){for(var u=0,r=w.length;u<r;u++){q+=a(w[u]);}return q;}if(!w.tag){w.tag="div";}q+="<"+w.tag;for(var p in w){if(p=="tag"||p=="children"||p=="cn"||p=="html"||typeof w[p]=="function"){continue;}if(p=="style"){var v=w["style"];if(typeof v=="function"){v=v.call();}if(typeof v=="string"){q+=' style="'+v+'"';}else{if(typeof v=="object"){q+=' style="';for(var t in v){if(typeof v[t]!="function"){q+=t+":"+v[t]+";";}}q+='"';}}}else{if(p=="cls"){q+= ' class="'+w["cls"]+'"';}else{if(p=="htmlFor"){q+=' for="'+w["htmlFor"]+'"';}else{q+=" "+p+'="'+w[p]+'"';}}}}if(g.test(w.tag)){q+="/>";}else{q+=">";var x=w.children||w.cn;if(x){q+=a(x);}else{if(w.html){q+=w.html;}}q+="</" +w.tag+">";}return q;};var o=function(v,q){var u;if(Ext.isArray(v)){u=document.createDocumentFragment();for(var t=0,r=v.length;t<r;t++){o(v[t],u);}}else{if(typeof v=="string"){u=document.createTextNode(v);}else{u=document.createElem ent(v.tag||"div");var s=!!u.setAttribute;for(var p in v){if(p=="tag"||p=="children"||p=="cn"||p=="html"||p=="style"||typeof v[p]=="function"){continue;}if(p=="cls"){u.className=v["cls"];}else{i f(s){u.setAttribute(p,v[p]);}else{u[p]=v[p];}}}Ext.DomHelper.applySty les(u,v.style);var w=v.children||v.cn;if(w){o(w,u);}else{if(v.html){u.innerHTML=v.html;} }}}if(q){q.appendChild(u);}return u;};var k=function(v,t,r,u){n.innerHTML=[t,r,u].join("");var p=- 1,q=n;while(++p<v){q=q.firstChild;}return q;};var l="<table>",e="</table>",c=l+"<tbody>",m="</tbody>"+e,i=c+"<tr>",d="< /tr>"+m;var h=function(p,q,s,r){if(!n){n=document.createElement("div");}var t;var u=null;if(p=="td"){if(q=="afterbegin"||q=="beforeend"){return;}if(q== "beforebegin"){u=s;s=s.parentNode;}else{u=s.nextSibling;s=s.parentNod e;}t=k(4,i,r,d);}else{if(p=="tr"){if(q=="beforebegin"){u=s;s=s.parent Node;t=k(3,c,r,m);}else{if(q=="afterend"){u=s.nextSibling;s=s.parentN ode;t=k(3,c,r,m);}else{if(q=="afterbegin"){u=s.firstChild;}t=k(4,i,r, d);}}}else{if(p=="tbody"){if(q=="beforebegin"){u=s;s=s.parentNode;t=k (2,l,r,e);}else{if(q=="afterend"){u=s.nextSibling;s=s.parentNode;t=k( 2,l,r,e);}else{if(q=="afterbegin"){u=s.firstChild;}t=k(3,c,r,m);}}}el se{if(q=="beforebegin"||q=="afterend"){return;}if(q=="afterbegin"){u= s.firstChild;}t=k(2,l,r,e);}}}s.insertBefore(t,u);return 955KB -> 265KB 539KB -> 141KB
  • 22. Reduce HTTP Requests • Less components means a faster page • Every request is an overhead • Combine scripts • Combine CSS • Combine images into CSS Sprites • Don’t rely on cache: 304’s are still requests
  • 23. CSS Sprites • Combine all small images into one large image • Use CSS to control the displaying of each image
  • 24. The designers want what? 11 images 11 HTTP Requests 3.3 KB total size
  • 25. Obey your thirst® 1 image 1 HTTP Request 1.6 KB total size
  • 26. And the code? <div class="buttons"> <span class="large green button"> <button type="button"> <span class="checkbox icon"> Approve </span> </button> </span> <span class="large blue button"> <button type="button"> <span> Save </span> </button> </span> <span class="large red button"> <button type="button"> <span class="delete icon"> Delete </span> </button> </span> <span class="medium gray button"> <button type="button"> <span class="delete icon"> Cancel </span> </button> </span> </div> .buttons span.button { background:transparent url(buttons.png) no-repeat 0 0; } .buttons span.button button, .buttons span.button a { background:transparent url(buttons.png) no-repeat 100% -120px; } .buttons span.blue { background-position: 0 -30px; } .buttons span.blue button, .buttons span.blue a { background-position: 100% -150px; } .buttons span.red { background-position: 0 -60px; } .buttons span.red button, .buttons span.red a { background-position: 100% -180px; } .buttons span.green { background-position: 0 -90px; } .buttons span.green button, .buttons span.green a { background-position: 100% -210px; }
  • 28. Optimise images • Use PNGs instead of GIFs • Avoid alpha filters – can block rendering and freeze the browser • PNG8 is best and supported by IE6 (yes – even with transparency • Optimise further with tools like PNGOUT • Make sure you have a favicon.ico: • Every browser will request it • Best not to respond with a 404 • Make it small and cacheable
  • 30. Maximise Parallel Downloads • Most browsers are limited to 6 connections total and 2 connections per hostname Browser Parallel Downloads Firefox 3.x 6 Internet Explorer 7 2 Internet Explorer 8 6 Safari 3.x 4 Safari 4 4 Chrome 4 • Increase the number of hostnames to increase the number of parallel downloads • Don't overdo it! (DNS lookups are expensive so limit to 2-4 domains)
  • 31.
  • 32.
  • 33. JavaScript external and on the bottom • Move scripts to external files for both reuse and caching • Promotes better script design • Push scripts as low as possible – Often difficult with document.write or with inline calls requiring loaded JavaScript – Be pragmatic – think about splitting JavaScript into “must be loaded” and “can be loaded on demand” • Scripts will block both downloading and rendering until parsed • Remove duplicate scripts (IE has a habit of downloading them again)
  • 34. Maximise the cache • Understand the ratio of users with cached vs uncached • Add an Expires header – Not just for images – should be used on all static content – Set a “Never expire” or far future expires policy if you can – Reduces HTTP requests – once component is served, the browser never asks for it again – Date stamping in file names makes it easier • Remove ETags – ETags are another caching mechanism – sent with every request – Uniquely created per web server – not good in web farms – Just turn them off and use Expires headers instead
  • 35. Use a CDN • Content Delivery Network • Distributes content closer to the last mile • Distribute your static content before distributing your dynamic content • Akamai most popular but expensive for small sites • Xero utilises a rudimentary CDN using IP lookup to determine location
  • 36. GET Request Response with HTML document Images JS CSS How it works: RegisterCSS("/common/style/xero.css", "screen") RegisterJavascript("/common/scripts/xero.js") <link rel="stylesheet" type="text/css" media="screen" href="https://nzs1.xero.com/common/style/xero.css" /> <script type="text/javascript" src="https://nzs2.xero.com/common/scripts/xero.js"> </script> Get location from IP
  • 37. Reduce cookie weight • Cookies are sent back with every request • Keep cookie size small and only store what's required – use server-side storage for everything else • Consider cookie free domains for static content • And while we're at it – reduce ViewState too!
  • 38. Preloading … • Preload components you’ll need in the future • Unconditional preload – Xero login page preloads all core components so that the dashboard experience is better • Conditional preload – Often based on where you think a user might go to next
  • 39. YSlow • Firebug extension • Grades performance – not about response times but about how well a site has adopted the techniques suggested • Response time inversely proportional to YSlow score – get as close to A as possible to get the maximum performance gain
  • 40. YSlow
  • 41. Aptimize • Plugin that works with both IIS & Apache • Merges CSS & JSS files • Reduces & optimises images with CSS sprites & CSS inlining • Compresses content with minification • Improves caching • Used by over 300 websites & intranets • And it does all this in real-time! www.aptimize.com
  • 43. Aptimizing Microsoft • Microsoft used Aptimize to speed up sharepoint.microsoft.com • HTTP requests reduced from 96 to 35 • Sped up first view, repeat view and start render by over 50% • YSlow went from an E to a B
  • 44. Things to take away • Focus on the front-end • Be an advocate for your users – isn't it nice to have happy users? • Faster web sites lead to: – Better user experience – Reduced operating expenses – Increase revenue
  • 45.